import { MockRequest } from '@delon/mock'
import { OperationsService } from 'app/routes/operations/operations-abstract.service'
const trans = {
  agentCode: 'A000008',
  agentName: 'cindy 交易测试集团 0821 勿动',
  agentNameEN: 'cindy trans test acq 0821 dd',
  category: 'qr',
  chanCode: 'WXP',
  createdAt: '2019-10-08T16:14:22.383+08:00',
  currency: 'JPY',
  insCode: '00090821',
  insName: 'cindy 测试交易 机构0821 勿动',
  insNameEN: 'cindy test trans acq 0821 do not',
  intMerCode: 'M000011',
  intStoreCode: 'S000172',
  merName: 'cindy 交易商户测试 勿动 0821 A',
  merNameEN: 'cindy trans merchat 0821 dont',
  merNum: 'M000082101',
  orderNum: 'P9910085846296421',
  paymentBrand: 'WXP',
  procFlag: '2',
  revFlag: '0',
  storeName: 'cindy ALP-UPI-WXP 渠道',
  storeNameEN: 'cindy ALP-UPI-WXP channel',
  storeNum: 'S000172',
  transAmt: 1,
  transScene: 'web-pay',
  transType: 1,
}
const data = [
  {
    disputeNum: '1',
    storeName: '这是一个测试门店',
    storeNameEN: 'en-',
    channel: 'WXP',
    type: 'Retrival',
    chargeAmt: 5,
    currency: 'CNY',
    status: 'todo',
    refNum: '2132323',
    cardNum: '1312845934899',
    authCode: '12323143',
    ARN: '1231234432',
    reasonCode: '123',
    handleMethod: 'close',
    createdAt: '2019-10-08T16:14:22.395+08:00',
    updatedAt: '2019-10-08T16:14:22.395+08:00',
  },
  {
    disputeNum: '2',
    storeName: '这是一个测试门店',
    storeNameEN: 'en-',
    channel: 'WXP',
    type: 'Chargeback',
    chargeAmt: 5,
    currency: 'CNY',
    status: 'todo',
    refNum: '2132323',
    cardNum: '1312845934899',
    authCode: '12323143',
    ARN: '1231234432',
    reasonCode: '123',
    handleMethod: 'close',
    createdAt: '2019-10-08T16:14:22.395+08:00',
    updatedAt: '2019-10-08T16:14:22.395+08:00',
  },
  {
    disputeNum: '3',
    storeName: '这是一个测试门店',
    storeNameEN: 'en-',
    channel: 'WXP',
    type: 'Second-Chargeback',
    chargeAmt: 5,
    currency: 'JPY',
    status: 'todo',
    refNum: '2132323',
    cardNum: '1312845934899',
    authCode: '12323143',
    ARN: '1231234432',
    reasonCode: '123',
    handleMethod: 'close',
    createdAt: '2019-10-08T16:14:22.395+08:00',
    updatedAt: '2019-10-08T16:14:22.395+08:00',
  },
  {
    disputeNum: '4',
    storeName: '这是一个测试门店',
    storeNameEN: 'en-',
    channel: 'WXP',
    type: 'Reject',
    chargeAmt: 5,
    currency: 'CNY',
    status: 'todo',
    refNum: '2132323',
    cardNum: '1312845934899',
    authCode: '12323143',
    ARN: '1231234432',
    reasonCode: '123',
    handleMethod: 'close',
    createdAt: '2019-10-08T16:14:22.395+08:00',
    updatedAt: '2019-10-08T16:14:22.395+08:00',
  }
]
const getList = (params: any) => {
  return {
    total: 1,
    count: 1,
    page: 1,
    size: 10,
    data,
  }
}

const getDetail = (disputeNum: string) => {
  const detail = data.find(d => d.disputeNum === disputeNum)
  return {...detail, trans}
}

const operate = (body) => {
  return { code: 'MSG_CODE.SYSTEM.SUCCESS', msg: 'MSG_CODE.SYSTEM.SUCCESS'}
}

export const CHARGE_BACKS = {
  '/charge/list': (req: MockRequest) => getList(req.queryString),
  '/charge/:disputeNum': (req: MockRequest) => getDetail(req.params.disputeNum),
  'POST /charge/operate': (req: MockRequest) => operate(req.body),
}
